{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Math in Python [demonstration]\n",
    "The code below demonstrates some common mathematical operations in python as well as usage of Python's `isinstance` function."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Math in Python\n",
    "\n",
    "Run the cell below to see examples of using math in Python. The math library contains many methods including a method that ouputs the value of pi."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import math\n",
    "\n",
    "radius        = 10.0\n",
    "diameter      = 2 * radius\n",
    "circumference = 2 * math.pi * radius\n",
    "area          = math.pi * radius ** 2\n",
    "\n",
    "print(\"Radius is\", radius)\n",
    "print(\"Diameter is\", diameter)\n",
    "print(\"Circumference is\", circumference)\n",
    "print(\"Area is\", area)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### isinstance() function\n",
    "\n",
    "In the next code cell, you will see how the isinstance() function works. \n",
    "\n",
    "The isinstance() function checks to see if a variable holds a certain type of value like an integer, float, string, etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sqr_root_2 = math.sqrt(2)\n",
    "is_sqr_root_2_an_integer = isinstance(sqr_root_2, int)\n",
    "print(\"Is square root two an integer?\", is_sqr_root_2_an_integer)\n",
    "\n",
    "is_sqr_root_2_a_float = isinstance(sqr_root_2, float)\n",
    "print(\"Is square root two a float?\", is_sqr_root_2_a_float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
